package ${dtoPkg};

<#--导包-->
<#compress>
<#if GeneratorInfo.hasSwagger == "1">
import io.swagger.v3.oas.annotations.media.Schema;
</#if>
<#if hasDateFormat == true>
  import org.springframework.format.annotation.DateTimeFormat;
</#if>

import lombok.Data;
import javax.validation.constraints.NotNull;
import cn.lycode.common.utils.SecurityUtils;
import java.util.Date;
import ${entityPkg}.${entityClassName};
<#list importPackages as pkg>
import ${pkg};
</#list>

</#compress>

/**
 * ${entityClassName}修改DTO
 *
 * @since ${datetime}
 * @author ${author}
 */
@Data
<#if GeneratorInfo.hasSwagger == "1">
@Schema(description = "${entityClassName}修改DTO")
</#if>
public class ${dtoUpdateClassName} {

<#list columns as field>
  <#if field.isPk =="1">
    <#if GeneratorInfo.hasSwagger == "1">
    @Schema(description =  "${field.columnComment}")
    </#if>
    @NotNull(message = "id不能为空")
    private ${field.javaType} ${field.javaField}; //${field.columnComment}
  </#if>
  <#if field.isEdit == "1" && field.isPk == "0" >
    <#if field.javaType == "LocalDateTime">
    <#if GeneratorInfo.hasSwagger == "1">
    @Schema(description =  "${field.columnComment}")
    </#if>
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private ${field.javaType} ${field.javaField}; //${field.columnComment}
    <#else>
    <#if GeneratorInfo.hasSwagger == "1">
    @Schema(description =  "${field.columnComment}")
    </#if>
    private ${field.javaType} ${field.javaField}; //${field.columnComment}
    </#if>
  </#if>
</#list>

  public ${entityClassName} buildUpEntity() {
    ${entityClassName} ${camelClassName} = new ${entityClassName}();
    <#list columns as field>
      <#if field.isEdit == "1" >
    ${camelClassName}.set${field.upCamelField}(this.${field.javaField});
      </#if>
    </#list>
    ${camelClassName}.setUpdateTime(new Date());
    ${camelClassName}.setUpdateBy(SecurityUtils.getLoginUsername());
    return ${camelClassName};
  }

}